package dao

import javax.inject.Inject
import models.Tables._
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.jdbc.JdbcProfile

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

/**
 * Created by yz on 2018/7/17
 */
class SoftDao @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends
  HasDatabaseConfigProvider[JdbcProfile] {

  import profile.api._

  type MyRow = SoftRow
  val table = Soft

  def selectAll = db.run(table.result)

  def select(name: String) = db.run(table.filter(_.name === name).result.head)

  def update(row: MyRow) = db.run(table.filter(_.name === row.name).update(row)).map(_ => ())


}
